package dataService;

import java.util.Arrays;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.ws.rs.core.MultivaluedMap;

import logic.Config;

public class OAuthRequestWrapper extends HttpServletRequestWrapper{ 

  //  private MultivaluedMap<String, String> form; 
//MultivaluedMap<String, String> form
    public OAuthRequestWrapper(HttpServletRequest request) { 
        super(request); 
    //    this.form = form; 
    } 
    
    @Override
    public String getContentType()
    {
    	
    	return "application/x-www-form-urlencoded";
    }
    
    @Override
    public String getMethod()
    {
    	
    	return "POST";
    }
    
    @Override 
    public String getParameter(String name) { 
        String value = super.getParameter(name); 
        /*if (value == null) { 
            value = form.getFirst(name); 
        } */
        
        if(name.equals("client_secret"))
        {
        	if(super.getParameter("client_id")==null) return "clientsecret";
        	else return super.getParameter("client_id");
        }
        return value; 
    } 
} 